﻿<!--//=============================================================
    // Copyright (C) 2015 福流网络
    // 作 者：钟星星
    // 日 期：2016-02-22
    // 描 述:  报关业务下的快递单设置
    // 版 本：1.00
    // 修改历史纪录
    // 版 本  修改时间      修改人            修改内容
    //=============================================================-->

<table>
    <tr>
        <td>
            模板名称
        </td>
        <td>
            <input class="mini-combobox" style="width:150px;" id="comExport" url="/Share/GetJsonList?tablename=t_customer_fees_tmp&fieldnames=id,tmp_name&where=tmp_type='v_t_express'&searchField=" textfield="tmp_name" valuefield="id" allowinput="false" />
       
            <!--<input id="comExport" name="comExport" shownullitem="true" class="mini-combobox" style="width: 150px;"
                   data="[{id:279,text:'寄单统计表'}]" textfield="text" valuefield="id" />-->
            
            <!--<div id="comExport" name="comExport" class="mini-combobox" style="width:100%;" popupwidth="200" allowinput="true" textfield="short" valuefield="id" value="0"
                 showclose="true" valuefromselect="true" url="../../../Share/GetJsonList?tablename=t_base_objs&fieldnames=id,zucode,short&where=zclass_id=500&searchField=short,zucode" oncloseclick="onCloseClick">
                <div property="columns">
                    <div header="编号" field="zucode"></div>
                    <div header="简称" field="short"></div>
                </div>
            </div>-->
            

            <a class="mini-button" iconcls="icon_find" onclick="fnExportMuBan()">导出</a>
        
        </td>
    </tr>
</table>

<!--导出Excel相关HTML-->
<iframe id="exportIFrame" name="excelIFrame" style="display: none"></iframe>

<!--导出Excel相关HTML-->
<form id="excelForm" action="" method="post" target="excelIFrame">
    <input type="hidden" name="json" id="hidColumnsData" />   <!--要导出列的数据*@-->
    <input type="hidden" name="condition" id="hidCondition" />  <!--@*视图名称*@-->
    <input type="hidden" name="tmpId" id="hidTmpId" />     <!--@*导出模板id*@-->
    <input type="hidden" name="tmpName" id="hidTmpName" />  <!--@*导出模板名称*@-->
</form>

<iframe id="excelIFrame" name="excelIFrame" style="display: none"></iframe>


<script type="text/javascript">

    //导出按钮
    function fnExportMuBan() {

        var condition = fnGetCondition("QueryItem"); //获取页面上的查询条件

        //var condition = conditionDate.replace("%", "%25");
       // var condition = encodeURI(conditionDate);  //url路径转化

        var exportData = fnGetData("t_customer_fees_tmp").data; //获取导出名称
        var tmpId = mini.get("comExport").getValue(); //获取模板ID

        if (tmpId == "") {
            mini.alert("请选择导出模板!");
            return;
        }
        $("#hidTmpId").val(tmpId);
        $("#hidCondition").val(condition);
        var msg = mini.loading("数据处理中，请稍后......", "系统消息提醒");
        var tmpType = Enumerable.From(exportData).Where(function (x) { return x.id == tmpId; }).ToArray();
        var tmpName = tmpType[0].tmp_name;
        $("#hidTmpName").val(tmpName);
        var columns = GetColumns("datagrid1");
        var json = mini.encode(columns);
        $("#hidColumnsData").val(json);
        var excelForm = document.getElementById("excelForm");

        excelForm.action = "../../CustomsExpress/ExportTmpExcel";
        excelForm.submit();
        mini.hideMessageBox(msg);
    }


    function GetColumns(gridName) {
        var grid = mini.get(gridName);
        var columns = grid.getBottomColumns();
        columns = columns.clone();
        for (var i = columns.length - 1; i >= 0; i--) {
            var column = columns[i];
            if (!column.field) {
                columns.removeAt(i);
            } else {
                var c = { header: column.header, field: column.field };
                columns[i] = c;
            }
        }
        return columns;

    }





</script>